package com.example.robertluozizhao.framecollectdemo.adapter.holder;

import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.robertluozizhao.framecollectdemo.R;
import com.google.android.flexbox.FlexboxLayoutManager;

/**
 * Created by robert.luozizhao on 2018/1/29.
 */

public class FlexViewHolder extends RecyclerView.ViewHolder {

    private TextView tvFlexTest;

    public FlexViewHolder(View itemView) {
        super(itemView);
        ViewGroup.LayoutParams lp = itemView.getLayoutParams();
        if (lp instanceof FlexboxLayoutManager.LayoutParams) {
            FlexboxLayoutManager.LayoutParams flexboxLp = (FlexboxLayoutManager.LayoutParams) lp;
            flexboxLp.setFlexGrow(1.0f);
        }
         tvFlexTest = itemView.findViewById(R.id.tv_flex_test);
    }

    public  void setText(int width){
        tvFlexTest.setWidth(width);
    }

    public TextView getTvFlexTest(){
        return tvFlexTest;
    }
}
